package org.wu.framework.authorization.platform.application.impl;

import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.authorization.platform.application.LazyZoneApplicationVersionApplication;
import org.wu.framework.web.response.Result;
import org.wu.framework.authorization.platform.domain.model.lazy.zone.application.version.LazyZoneApplicationVersion;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.version.LazyZoneApplicationVersionRemoveCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.version.LazyZoneApplicationVersionStoryCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.version.LazyZoneApplicationVersionUpdateCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.version.LazyZoneApplicationVersionQueryListCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.version.LazyZoneApplicationVersionQueryOneCommand;
import org.wu.framework.authorization.platform.application.assembler.LazyZoneApplicationVersionDTOAssembler;
import org.wu.framework.authorization.platform.application.dto.LazyZoneApplicationVersionDTO;
import java.util.stream.Collectors;
import jakarta.annotation.Resource;
import org.wu.framework.authorization.platform.domain.model.lazy.zone.application.version.LazyZoneApplicationVersionRepository;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe 应用版本 
 *
 * @author Jia wei Wu
 * @date 2024/04/02 06:21 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl 
 **/
@LazyApplication
public class LazyZoneApplicationVersionApplicationImpl implements LazyZoneApplicationVersionApplication {

    @Resource
    LazyZoneApplicationVersionRepository lazyZoneApplicationVersionRepository;
    /**
     * describe 新增应用版本
     *
     * @param lazyZoneApplicationVersionStoryCommand 新增应用版本     
     * @return {@link Result<LazyZoneApplicationVersion>} 应用版本新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersion> story(LazyZoneApplicationVersionStoryCommand lazyZoneApplicationVersionStoryCommand) {
        LazyZoneApplicationVersion lazyZoneApplicationVersion = LazyZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(lazyZoneApplicationVersionStoryCommand);
        return lazyZoneApplicationVersionRepository.story(lazyZoneApplicationVersion);
    }
    /**
     * describe 批量新增应用版本
     *
     * @param lazyZoneApplicationVersionStoryCommandList 批量新增应用版本     
     * @return {@link Result<List<LazyZoneApplicationVersion>>} 应用版本新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<LazyZoneApplicationVersion>> batchStory(List<LazyZoneApplicationVersionStoryCommand> lazyZoneApplicationVersionStoryCommandList) {
        List<LazyZoneApplicationVersion> lazyZoneApplicationVersionList = lazyZoneApplicationVersionStoryCommandList.stream().map( LazyZoneApplicationVersionDTOAssembler.INSTANCE::toLazyZoneApplicationVersion).collect(Collectors.toList());
        return lazyZoneApplicationVersionRepository.batchStory(lazyZoneApplicationVersionList);
    }
    /**
     * describe 更新应用版本
     *
     * @param lazyZoneApplicationVersionUpdateCommand 更新应用版本     
     * @return {@link Result<LazyZoneApplicationVersion>} 应用版本领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersion> updateOne(LazyZoneApplicationVersionUpdateCommand lazyZoneApplicationVersionUpdateCommand) {
        LazyZoneApplicationVersion lazyZoneApplicationVersion = LazyZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(lazyZoneApplicationVersionUpdateCommand);
        return lazyZoneApplicationVersionRepository.story(lazyZoneApplicationVersion);
    }

    /**
     * describe 查询单个应用版本
     *
     * @param lazyZoneApplicationVersionQueryOneCommand 查询单个应用版本     
     * @return {@link Result<LazyZoneApplicationVersionDTO>} 应用版本DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersionDTO> findOne(LazyZoneApplicationVersionQueryOneCommand lazyZoneApplicationVersionQueryOneCommand) {
        LazyZoneApplicationVersion lazyZoneApplicationVersion = LazyZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(lazyZoneApplicationVersionQueryOneCommand);
        return lazyZoneApplicationVersionRepository.findOne(lazyZoneApplicationVersion).convert(LazyZoneApplicationVersionDTOAssembler.INSTANCE::fromLazyZoneApplicationVersion);
    }

    /**
     * describe 查询多个应用版本
     *
     * @param lazyZoneApplicationVersionQueryListCommand 查询多个应用版本     
     * @return {@link Result<List<LazyZoneApplicationVersionDTO>>} 应用版本DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<LazyZoneApplicationVersionDTO>> findList(LazyZoneApplicationVersionQueryListCommand lazyZoneApplicationVersionQueryListCommand) {
        LazyZoneApplicationVersion lazyZoneApplicationVersion = LazyZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(lazyZoneApplicationVersionQueryListCommand);
        return lazyZoneApplicationVersionRepository.findList(lazyZoneApplicationVersion)        .convert(lazyZoneApplicationVersions -> lazyZoneApplicationVersions.stream().map(LazyZoneApplicationVersionDTOAssembler.INSTANCE::fromLazyZoneApplicationVersion).collect(Collectors.toList())) ;
    }

    /**
     * describe 分页查询多个应用版本
     *
     * @param lazyZoneApplicationVersionQueryListCommand 分页查询多个应用版本     
     * @return {@link Result<LazyPage<LazyZoneApplicationVersionDTO>>} 分页应用版本DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyPage<LazyZoneApplicationVersionDTO>> findPage(int size,int current,LazyZoneApplicationVersionQueryListCommand lazyZoneApplicationVersionQueryListCommand) {
        LazyZoneApplicationVersion lazyZoneApplicationVersion = LazyZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(lazyZoneApplicationVersionQueryListCommand);
        return lazyZoneApplicationVersionRepository.findPage(size,current,lazyZoneApplicationVersion)        .convert(page -> page.convert(LazyZoneApplicationVersionDTOAssembler.INSTANCE::fromLazyZoneApplicationVersion))            ;
    }

    /**
     * describe 删除应用版本
     *
     * @param lazyZoneApplicationVersionRemoveCommand 删除应用版本     
     * @return {@link Result<LazyZoneApplicationVersion>} 应用版本     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersion> remove(LazyZoneApplicationVersionRemoveCommand lazyZoneApplicationVersionRemoveCommand) {
     LazyZoneApplicationVersion lazyZoneApplicationVersion = LazyZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(lazyZoneApplicationVersionRemoveCommand);
     return lazyZoneApplicationVersionRepository.remove(lazyZoneApplicationVersion);
    }

}